package com.liancheng.smarthome.module;

import com.liancheng.smarthome.R;
import com.liancheng.smarthome.base.BaseActivity;
import com.liancheng.smarthome.base.TitleEventListener;
import com.liancheng.smarthome.bean.InputTitleBean;
import com.liancheng.smarthome.bean.PageTitleBean;
import com.liancheng.smarthome.databinding.ForgetPwdView;
import com.liancheng.smarthome.utils.common.StringUtils;
import com.liancheng.smarthome.utils.logs.LogTag;
import com.liancheng.smarthome.base.TitleEventModule;

public class ForgetPwdActivity extends BaseActivity<ForgetPwdVM,ForgetPwdView>
        implements TitleEventListener.OnClickLeftImg,TitleEventListener.OnClickRightTitle {

    private PageTitleBean pageTitleBean;
    private InputTitleBean nowPwd;
    private InputTitleBean newPwd;
    private InputTitleBean newPwdSure;

    @Override
    public int getLayoutId() {
        return R.layout.activity_forget_pwd;
    }

    @Override
    public void afterCreate() {
        pageTitleBean = new PageTitleBean(R.mipmap.icon_back_left_white, "修改密码", "保存");
        contentView.setPageTitle(pageTitleBean);
        contentView.setForgetpwdEvent(VM);
        //没有将触发对象放入到 contentView 导致点击事件触发失败
        contentView.setTitleEvent(new TitleEventModule(this,this));
//        contentView.setView(new View(this));

        nowPwd = new InputTitleBean("当前密码","请输入当前密码","");
        newPwd = new InputTitleBean("新密码","请输入密码","");
        newPwdSure = new InputTitleBean("新密码确认","请再次输入新密码","");


        contentView.setInputNow(nowPwd);
        contentView.setInputNew(newPwd);
        contentView.setInputNewSure(newPwdSure);

    }

    @java.lang.Override
    public void clickLeftImg() {
        this.finish();
    }

    /**
     * 保存密码的方法 saveNewPwd
     */
    @java.lang.Override
    public void clickRightTitle() {
////新密码的格式为：8~16位字母和数字组合
        LogTag.d("nowPwd-->"+nowPwd);
        LogTag.d("newPwd-->"+newPwd);
        LogTag.d("newPwdSure-->"+newPwdSure);

        newPwdSure.setEdtText("我是改了存值的输入框");
        boolean numZImu816 = StringUtils.isNumZImu816(newPwd.edtText);
//        if (TextUtils.isEmpty(phone)) {
//            ToastUtil.showLong(context, R.string.str_phone_not_null);
//            return;
//        }
//        if (!StringUtil.phoneisNum1011(phone)) {
//            ToastUtil.showLong(context, R.string.str_enter_phone_format);
//            return;
//        }
//        if (TextUtils.isEmpty(code)) {
//            ToastUtil.showLong(context, R.string.str_code_nonull);
//            return;
//        }
//        if (TextUtils.isEmpty(newPwd)) {
//            ToastUtil.showLong(context, R.string.str_pwd_notnull);
//            return;
//        }
//        if (!StringUtil.isNumZImu816(newPwd)) {
//            //检查密码格式
//            ToastUtil.showLong(context, R.string.str_password_pwd_incorrect_format);
//            return;
//        }
//        if(!newPwd.equals(againPwd)){
//            ToastUtil.showLong(context, R.string.str_password_is_not_same);
//            return;
//        }
//        presenter.resetPassword(phone,code,newPwd);
    }

}
